//
//  Live_BaseController.m
//  YLProject
//
//  Created by 张伯林 on 2018/1/17.
//  Copyright © 2018年 WY. All rights reserved.
//

#import "Live_BaseController.h"
#import "Live_HotCell.h"
#import "Live_NewPlaherController.h"
@interface Live_BaseController ()<UICollectionViewDelegate,UICollectionViewDataSource>

@end

@implementation Live_BaseController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.collectionView];
}
//-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
//    return 1;
//}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 10;
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(10, 10, 10, 10);
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    Live_HotCell *cell = [_collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([Live_HotCell class]) forIndexPath:indexPath];
    cell.backgroundColor = [UIColor purpleColor];
    cell.layer.masksToBounds = YES;
    cell.layer.cornerRadius = 5;
    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    Live_NewPlaherController *live = [[Live_NewPlaherController alloc]init];
    [self presentViewController:live animated:YES completion:^{
        NSLog(@"----直播界面");
    }];
}
-(UICollectionView *)collectionView{
    if (!_collectionView) {
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
        flowLayout.itemSize = CGSizeMake((Screen_Width - 30) / 2, (Screen_Width - 30) / 2 + 30);
        flowLayout.minimumLineSpacing = 10;
        flowLayout.minimumInteritemSpacing = 10;
        _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 35, Screen_Width, Screen_Height - (STATUS_BAR_HEIGHT + 44 + 35)) collectionViewLayout:flowLayout];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        [_collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([Live_HotCell class]) bundle:nil] forCellWithReuseIdentifier:NSStringFromClass([Live_HotCell class])];
        _collectionView.backgroundColor = kHEXCOLOR(@"f4f5f7");
    }
    return _collectionView;
}
-(NSMutableArray *)dataSource{
    if (!_dataSource) {
        _dataSource = [NSMutableArray array];
    }
    return _dataSource;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
